// SPDX-FileCopyrightText: Copyright 2025-2025 深圳市同心圆网络有限公司 
// SPDX-License-Identifier: GPL-3.0-only 

import { get_server_config, type ServerConfigInfo } from "$lib/api/config";


export class AppStore {
  public darkMode = $state(false);

  public showConfigModal = $state(false);

  private _serverCfg: ServerConfigInfo = $state({
    can_user_register: false,
    quick_user_register: false,
  });

  get serverCfg() {
    return this._serverCfg;
  }

  async initServerCfg() {
    try {
      const res = await get_server_config({});
      this._serverCfg = res.config;
    } catch (e) {
      console.log(e);
      this._serverCfg = {
        can_user_register: false,
        quick_user_register: false,
      };
    }
  }
}

export const appStore = $state(new AppStore());
